package org.aeon.gamechatnest.dto;

import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Pattern;
import lombok.Data;
import org.aeon.gamechatnest.validated.Login;
import org.aeon.gamechatnest.validated.annotation.AnyNotEmpty;
import org.springframework.data.mongodb.core.mapping.Document;

import java.io.Serial;
import java.io.Serializable;

/**
 * @author: MissingAeon
 * @date: 2024/5/9 15:19
 * @description: 用户登录dto
 */
@Schema(description = "用户实体", name = "UserLoginDto")
@Data
@Document("user")
public class UserLoginDto implements Serializable {
    @Serial
    private static final long serialVersionUID = 1L;
    /**
     * 用户名
     */
    @Schema(description = "用户名", name = "username")
    @Pattern(groups = {Login.class}, regexp = "[\\u4e00-\\u9fff\\w]*#\\d+", message = "用户名格式错误")
    @AnyNotEmpty(groups = {Login.class}, value = 1, clazz = UserLoginDto.class)
    private String username;
    /**
     * 密码
     */
    @Schema(description = "密码", name = "password")
    @NotBlank(groups = {Login.class}, message = "密码不能为空")
    private String password;
    /**
     * 手机号
     */
    @Schema(description = "手机号", name = "phone")
    @Pattern(groups = {Login.class}, regexp = "^1[3-9]\\d{9}$", message = "手机号格式错误")
    @AnyNotEmpty(groups = {Login.class}, value = 1, clazz = UserLoginDto.class)
    private String phone;
    /**
     * 邮箱号
     */
    @Schema(description = "邮箱号", name = "email")
    @Pattern(groups = {Login.class}, regexp = "^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\\.[a-zA-Z0-9_-]+)+$", message = "邮箱号格式错误")
    @AnyNotEmpty(groups = {Login.class}, value = 1, clazz = UserLoginDto.class)
    private String email;
}
